package com.forezp.thinking.chapter18;

import java.io.*;

/**
 * Created by forezp on 2017/12/8.
 */
public class BufferedInputFile {

    public static final String FILE_NAME = "/Users/forezp/IdeaProjects/java-study/pom.xml";


    public static String readFile(String filename) throws IOException {
        File file = new File(filename);
        BufferedReader in = new BufferedReader(new FileReader(file));
        StringBuffer stringBuffer = new StringBuffer();//支持并发操作 同步
        String s;
        while ((s = in.readLine()) != null) {
            stringBuffer.append(s + "\n");
        }

        in.close();
        return stringBuffer.toString();

    }

    public static void main(String[] args) throws IOException {
        System.out.println(readFile("/Users/forezp/IdeaProjects/java-study/pom.xml").toString());
    }
}
